<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('工资详情列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="hidden" id="salaryId" name="salaryId" th:value="${salaryId}">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>用户姓名：</label>
                                <input type="text" name="userName"/>
                            </li>
                            <li>
                                <label>工资类型：</label>
                                <select name="salaryType" id="salaryType" class="form-control">
                                    <option value="">全部</option>
                                    <option value="1">在职职工</option>
                                    <option value="2">退休职工</option>
                                    <option value="3">铁路退休职工</option>
                                    <option value="4">临时工</option>
                                </select>
                            </li>
                            <li>
                                <label>职位类别：</label>
                                <select name="userPosition" th:with="type=${@dict.getType('basic_user_position')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="add()">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-info" onclick="importExcel()">
                    <i class="fa fa-upload"></i> 导入
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-table-fixed-columns-js" />
    <script th:inline="javascript">
        var prefix = ctx + "record/salary/content";

        var positions = [[${@dict.getType('basic_user_position')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add/{id}",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                importUrl: prefix + "/importData",
                modalName: "工资详情",
                fixedColumns: true,
                fixedNumber: 4,
                columns: [{
                    checkbox: true
                },
                {
                    field: 'contentId',
                    title: '内容id',
                    visible: false
                },
                {
                    field: 'userName',
                    title: '用户姓名',
                    sortable: true
                },
                {
                    field: 'idCard',
                    title: '身份证号',
                    sortable: true
                },
                {
                    field: 'salaryType',
                    title: '工资类型',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if(value == '1') {
                            return '在职职工';
                        }else if(value == '2') {
                            return '退休职工';
                        }else if(value == '3') {
                            return '铁路退休';
                        }else if(value == '4') {
                            return '临时工';
                        }
                    }
                },
                {
                    field: 'userPosition',
                    title: '职位类别',
                    sortable: true,
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(positions, value);
                    }
                },
                {
                    field: 'a0',
                    title: '薪级工资'
                },
                {
                    field: 'a1',
                    title: '教护百分之十'
                },
                {
                    field: 'a2',
                    title: '基础绩效'
                },
                {
                    field: 'a31',
                    title: '基础绩效奖'
                },
                {
                    field: 'a3',
                    title: '岗位工资'
                },
                {
                    field: 'a4',
                    title: '效益工资四'
                },
                {
                    field: 'a5',
                    title: '夜班绩效'
                },
                {
                    field: 'a6',
                    title: '管理绩效'
                },
                {
                    field: 'a7',
                    title: '门诊考核绩效'
                },
                {
                    field: 'a8',
                    title: '会诊绩效'
                },
                {
                    field: 'a9',
                    title: '效益工资一'
                },
                {
                    field: 'a10',
                    title: '效益工资二'
                },
                {
                    field: 'a11',
                    title: '效益工资三'
                },
                {
                    field: 'a12',
                    title: '保健'
                },
                {
                    field: 'a13',
                    title: '发一'
                },
                {
                    field: 'a14',
                    title: '发二'
                },
                {
                    field: 'a15',
                    title: '发三'
                },
                {
                    field: 'a16',
                    title: '公务交贴'
                },
                {
                    field: 'a17',
                    title: '取暖费'
                },
                {
                    field: 'a18',
                    title: '独子'
                },
                {
                    field: 'a19',
                    title: '应发合计'
                },
                {
                    field: 'a20',
                    title: '会费'
                },
                {
                    field: 'a21',
                    title: '养老保险'
                },
                {
                    field: 'a22',
                    title: '医疗保险'
                },
                {
                    field: 'a23',
                    title: '失业保险'
                },
                {
                    field: 'a24',
                    title: '住房公积金'
                },
                {
                    field: 'a25',
                    title: '扣二'
                },
                {
                    field: 'a26',
                    title: '扣减'
                },
                {
                    field: 'a27',
                    title: '个人所得税'
                },
                {
                    field: 'a28',
                    title: '扣款合计'
                },
                {
                    field: 'a29',
                    title: '实发合计'
                },
                {
                    field: 'a30',
                    title: '计税基数'
                },
                {
                    field: 'a32',
                    title: '工资所属日'
                },
                {
                    field: 'a33',
                    title: '爱心一日捐'
                },
                {
                    field: 'a34',
                    title: '职业年金'
                },
                {
                    field: 'a35',
                    title: '在附5'
                },
                {
                    field: 'b1',
                    title: '月增离退休费'
                },
                {
                    field: 'b2',
                    title: '月增离退休补贴'
                },
                {
                    field: 'b3',
                    title: '物业补贴'
                },
                {
                    field: 'b4',
                    title: '退休补贴2'
                },
                {
                    field: 'b5',
                    title: '零五岗'
                },
                {
                    field: 'b6',
                    title: '按年龄增加'
                },
                {
                    field: 'b7',
                    title: '保留部分'
                },
                {
                    field: 'b8',
                    title: '护龄'
                },
                {
                    field: 'b9',
                    title: '房贴'
                },
                {
                    field: 'b10',
                    title: '房贴二'
                },
                {
                    field: 'b11',
                    title: '统一补贴'
                },
                {
                    field: 'b12',
                    title: '过节费'
                },
                {
                    field: 'b13',
                    title: '薪级工资'
                },
                {
                    field: 'b14',
                    title: '岗位津贴'
                },
                {
                    field: 'b15',
                    title: '零七增资'
                },
                {
                    field: 'b16',
                    title: '零八增资'
                },
                {
                    field: 'b17',
                    title: '遗属补助'
                },
                {
                    field: 'b18',
                    title: '补发'
                },
                {
                    field: 'b19',
                    title: '退休预支金'
                },
                {
                    field: 'b20',
                    title: '党支部工作补助'
                },
                {
                    field: 'b21',
                    title: '应发合计'
                },
                {
                    field: 'b22',
                    title: '扣二'
                },
                {
                    field: 'b23',
                    title: '大病保险'
                },
                {
                    field: 'b24',
                    title: '扣款合计'
                },
                {
                    field: 'b25',
                    title: '实发合计'
                },
                {
                    field: 'b26',
                    title: '年终奖'
                },
                {
                    field: 'b27',
                    title: '爱心一日捐'
                },
                {
                    field: 'b28',
                    title: '退附2'
                },
                {
                    field: 'b29',
                    title: '退附3'
                },
                {
                    field: 'b30',
                    title: '退附4'
                },
                {
                    field: 'c1',
                    title: '月增离退休费'
                },
                {
                    field: 'c2',
                    title: '国发八二号'
                },
                {
                    field: 'c3',
                    title: '工龄工资'
                },
                {
                    field: 'c4',
                    title: '九三工改增发'
                },
                {
                    field: 'c5',
                    title: '零六工改增发'
                },
                {
                    field: 'c6',
                    title: '月增离退休补贴'
                },
                {
                    field: 'c7',
                    title: '护龄津贴'
                },
                {
                    field: 'c8',
                    title: '三次职务补贴'
                },
                {
                    field: 'c9',
                    title: '零四岗'
                },
                {
                    field: 'c10',
                    title: '零五岗'
                },
                {
                    field: 'c11',
                    title: '生活补贴'
                },
                {
                    field: 'c12',
                    title: '地方补贴'
                },
                {
                    field: 'c13',
                    title: '物业补贴'
                },
                {
                    field: 'c14',
                    title: '工资附加'
                },
                {
                    field: 'c15',
                    title: '按年龄增加离退休费'
                },
                {
                    field: 'c16',
                    title: '乘车费'
                },
                {
                    field: 'c17',
                    title: '小房贴'
                },
                {
                    field: 'c18',
                    title: '房贴'
                },
                {
                    field: 'c19',
                    title: '护理费'
                },
                {
                    field: 'c20',
                    title: '统一补贴'
                },
                {
                    field: 'c21',
                    title: '节日费'
                },
                {
                    field: 'c22',
                    title: '离休待遇'
                },
                {
                    field: 'c23',
                    title: '移交互济'
                },
                {
                    field: 'c24',
                    title: '发一'
                },
                {
                    field: 'c25',
                    title: '一次性防暑降温费'
                },
                {
                    field: 'c26',
                    title: '应发合计'
                },
                {
                    field: 'c27',
                    title: '扣一'
                },
                {
                    field: 'c28',
                    title: '扣款合计'
                },
                {
                    field: 'c29',
                    title: '实发合计'
                },
                {
                    field: 'c30',
                    title: '年终奖'
                },
                {
                    field: 'c31',
                    title: '爱心一日捐'
                },
                {
                    field: 'c32',
                    title: '铁附2'
                },
                {
                    field: 'c33',
                    title: '铁附3'
                },
                {
                    field: 'c34',
                    title: '铁附4'
                },
                {
                    field: 'c35',
                    title: '铁附5'
                },
                {
                    field: 'd1',
                    title: '应发金额'
                },
                {
                    field: 'd2',
                    title: '疫情防控补贴'
                },
                {
                    field: 'd3',
                    title: '实发金额'
                },
                {
                    field: 'd4',
                    title: '岗位'
                },
                {
                    field: 'd5',
                    title: '补贴'
                },
                {
                    field: 'd6',
                    title: '夜班'
                },
                {
                    field: 'd7',
                    title: '绩效'
                },
                {
                    field: 'd8',
                    title: '总额'
                },
                {
                    field: 'd9',
                    title: '爱心一日捐'
                },
                {
                    field: 'd10',
                    title: '临附2'
                },
                {
                    field: 'remark',
                    title: '备注'
                }]
            };
            $.table.init(options);
        });

        function add(){
            var salaryId = $("#salaryId").val();
            $.operate.add(salaryId);
        }

        function importExcel() {
            var salaryType = $("#salaryType").val();
            if(salaryType == '') {
                $.modal.alertError("请先选择导入类型");
                return;
            }
            layer.open({
                type: 1,
                area: ['400px', '230px'],
                fix: false,
                //不固定
                maxmin: true,
                shade: 0.3,
                title: '导入到人员工资数据',
                content: $('#importTpl').html(),
                btn: ['<i class="fa fa-check"></i> 导入', '<i class="fa fa-remove"></i> 取消'],
                // 弹层外区域关闭
                shadeClose: true,
                btn1: function(index, layero){
                    var file = layero.find('#file').val();
                    if (file == '' || (!$.common.endWith(file, '.xls') && !$.common.endWith(file, '.xlsx'))){
                        $.modal.msgWarning("请选择后缀为 “xls”或“xlsx”的文件。");
                        return false;
                    }
                    var index = layer.load(2, {shade: false});
                    $.modal.disable();
                    var formData = new FormData(layero.find('form')[0]);
                    formData.set("salaryId", $("#salaryId").val());
                    formData.set("salaryType", $("#salaryType").val());
                    $.ajax({
                        url: table.options.importUrl,
                        data: formData,
                        cache: false,
                        contentType: false,
                        processData: false,
                        type: 'POST',
                        success: function (result) {
                            if (result.code == web_status.SUCCESS) {
                                $.modal.closeAll();
                                $.modal.alertSuccess(result.msg);
                                $.table.refresh();
                            } else if (result.code == web_status.WARNING) {
                                layer.close(index);
                                $.modal.enable();
                                $.modal.alertWarning(result.msg)
                            } else {
                                layer.close(index);
                                $.modal.enable();
                                $.modal.alertError(result.msg);
                            }
                        }
                    });
                }
            });
        }

        function importTemplate() {
            var salaryType = $("#salaryType").val();
            if(salaryType == '') {
                $.modal.alertError("请先选择导入类型");
                return;
            }
            var importTemplateUrl = prefix + "/importTemplate/" + salaryType;
            $.get(importTemplateUrl, function(result) {
                if (result.code == web_status.SUCCESS) {
                    window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                } else if (result.code == web_status.WARNING) {
                    $.modal.alertWarning(result.msg)
                } else {
                    $.modal.alertError(result.msg);
                }
            });
        }
    </script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果人员工资已经存在，更新这条数据。"> 是否更新已经存在的人员工资
                &nbsp;	<a onclick="importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>